import React ,{useEffect, useState}from 'react';
import { Button,  Form, Input, Select, Switch,DatePicker,message ,ConfigProvider} from 'antd';
import * as service from '../../../api/cyyindex'
import type { DatePickerProps } from 'antd';
import { useNavigate,  useSearchParams } from 'react-router-dom';
import dayjs from 'dayjs';
import 'dayjs/locale/zh-cn';
import locale from 'antd/locale/zh_CN';
import './entryadd.scss'
interface Props{

}
function EntryAdd(props: Props) {
   
  const [mydate, setMydate] = useState('')
  const [myday,setMyday]=useState('')
  const navigate = useNavigate()
  const [params,setParams]=useSearchParams()
  const [detailList,setDetailList]=useState<any>({})
  const [messageApi, contextHolder] = message.useMessage();

  const onChange1: DatePickerProps['onChange'] = (date, dateString) => {
    console.log(date, dateString);
 
    
setMydate(dateString)
  }; 
 
  const onFinish = (values: any) => {
    console.log('Success:', values);
    values.date=mydate
      service.entry_add1(values).then(res => {
        console.log(res)
        if (res.data.code == 200) {
          messageApi.open({
            type: 'success',
            content: '添加成功',
          });
          navigate('/index/staff/entry')
        } 
        
      })
  };

 

  
  const myJump = () => {
    navigate(-1)
  }
 
    return (
        <div className='entry-add'>
            <p className='title'>新增入职员工</p>
        <Form
       
    name="basic"
    labelCol={{ span: 8 }}
    wrapperCol={{ span: 16 }}
    
    initialValues={{ remember: true }}
    onFinish={onFinish}
    
    autoComplete="off"
  >

    <Form.Item
      label="姓名"
      name="name"
      rules={[{ required: true, message: 'Please input your username!' }]}
    >
      <Input />
    </Form.Item>



    <Form.Item name="station" label="部门组织">
        <Select
      defaultValue="请选择"
     options={[
        { value: '行政', label: '行政' },
        { value: '人事', label: '人事' },
        { value: '策划', label: '策划' },
        { value: '产品', label: '产品', },
        { value: '设计', label: '设计', },
        { value: '研发', label: '研发', },
      ]}
    />
    </Form.Item>
    <Form.Item
      label="职位"
       name="job"
    >
      <Select
      defaultValue="请选择"
    
      options={[
        { value: '产品经理', label: '产品经理' },
        { value: '设计主管', label: '设计主管' },
        { value: '设计师', label: '设计师' },
        { value: '前台', label: '前台',  },
      ]}
    />
    </Form.Item>
    <Form.Item
      label="手机号"
      name="tel"
      rules={[{ required: true, message: 'Please input your username!' }]}
    >
      <Input />
    </Form.Item>
    <Form.Item
      label="入职登记状态"
      name="entry"
      rules={[{ required: true, message: 'Please input your username!' }]}
    >
      <Select
      defaultValue="请选择"
      
      options={[
        { value: 1, label: '已入职' },
        { value: 2, label: '未入职' },
        { value:3, label: '已放弃' },
      ]}
    />
    </Form.Item>
    <Form.Item
      label="审批状态"
      name="status"
      rules={[{ required: true, message: 'Please input your username!' }]}
    >
      <Select
      defaultValue="请选择"
      
      options={[
        { value: 0, label: '未审批' },
        { value: 1, label: '已审批' },
        
      ]}
    />
    </Form.Item>
   
   
   
 

 
    <Form.Item
      label="入职日期"
      name="date"
          >
         
              <ConfigProvider locale={locale}>
              <DatePicker  onChange={onChange1} />
            </ConfigProvider>
         
      
                </Form.Item>
                <Form.Item
      label="来源"
      name="origin"
    >
      <Select
      defaultValue="请选择"
      
      options={[
        { value: '手动添加', label: '手动添加' },
        { value: '审批入职', label: '审批入职' },
        { value: '扫码入职', label: '扫码入职' },
      ]}
    />
    </Form.Item>
                <Form.Item
      label="添加人"
      name="person"
    >
      <Input />
    </Form.Item>

          <Form.Item wrapperCol={{ offset: 8, span: 16 }}>
           
                 <Button type="primary" htmlType="submit">
        保存
            </Button>
          
            
     
            <Button onClick={()=>{myJump()}}>取消</Button>
    </Form.Item>
    
        </Form>
        { contextHolder}
        </div>
    );
}

export default EntryAdd;